package org.liveboardgames.agricola.control.commands
{
    import com.adobe.cairngorm.commands.ICommand;
    import com.adobe.cairngorm.control.CairngormEvent;
    
    import org.liveboardgames.agricola.control.delegates.BuildPastureDelegate;
    import org.liveboardgames.agricola.control.events.BuildPastureEvent;
    import org.liveboardgames.agricola.model.AgricolaModelLocator;
    
    import mx.controls.Alert;
    import mx.rpc.IResponder;
    import mx.rpc.events.FaultEvent;
    
    public class BuildPastureCommand implements ICommand, IResponder
    {
        public function execute(event:CairngormEvent):void
        {
            var delegate:BuildPastureDelegate = new BuildPastureDelegate(this);
            var buildPastureEvent:BuildPastureEvent = BuildPastureEvent(event);
            delegate.buildPasture(buildPastureEvent.farm, buildPastureEvent.tiles);
        }
        
        public function result(data:Object):void
        {
        	// Do nothing, the model should be updated by the delegate
        }
        
        public function fault(info:Object):void
        {
            Alert.show("Could not build the pasture", "Error");
        }
    
    }
}